package org.antrain.pwd.utils;
import java.io.Serializable;

import lombok.Data;

@Data
public class Result implements Serializable{
    private static final long serialVersionUID = -6691656851198107463L;
    private int status;
    private String message;
    private Object data;

    /**
     *
     * @return 默认成功信息 （data=null, msg = SUCCESS , status = 200)
     */
    public static Result success() {
        return success("", Constants.SUCCESS_MSG, Constants.RESULT_CODE_SUCCESS);
    }

    /**
     *
     * @return 带数据的成功信息 （data=data, msg = SUCCESS , status = 200)
     */
    public static Result success(Object data) {
        return success(data, Constants.SUCCESS_MSG, Constants.RESULT_CODE_SUCCESS);
    }

    /**
     *
     * @return （data=data, msg = msg , status = 200)
     */
    public static Result success(Object data,String msg) {
        return success(data,msg, Constants.RESULT_CODE_SUCCESS);
    }

    /**
     *
     * @return （data=data, msg = msg , status = 200)
     */
    public static Result success(Object data,String msg,int code) {
        Result result = new Result();
        result.setData(data);
        result.setStatus(code);
        result.setMessage(msg);
        return result;
    }

    /**
     *
     * @return 默认成功信息 （data=null, msg = FAIL , status = 400)
     */
    public static Result failed() {
        return failed("", Constants.FAIL_MSG, Constants.RESULT_CODE_FAIL);
    }

    /**
     *
     * @return 带数据的成功信息 （data=data, msg = FAIL , status = 400)
     */
    public static Result failed(Object data) {
        return failed(data, Constants.FAIL_MSG, Constants.RESULT_CODE_FAIL);
    }

    /**
     *
     * @return （data=data, msg = msg , status = 400)
     */
    public static Result failed(Object data,String msg) {
        return failed(data,msg, Constants.RESULT_CODE_FAIL);
    }

    /**
     *
     * @return （data=data, msg = msg , status = 400)
     */
    public static Result failed(Object data,String msg,int code) {
        Result result = new Result();
        result.setData(data);
        result.setStatus(code);
        result.setMessage(msg);
        return result;
    }
}